package com.example.javaee.controller;

import com.example.javaee.domain.Grade;
import com.example.javaee.exception.LoginException;
import com.example.javaee.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequestMapping("grade")
public class GradeController {

    @Autowired
    private GradeService gradeService;

    @PostMapping("/saveGrade")
    public void saveGrade(@RequestBody Grade grade) throws LoginException {
        gradeService.saveGrade(grade);
    }

    @GetMapping("/{course}/likegrades")
    public String listGrade(@PathVariable("course") Long courseId){
        return gradeService.getCourseLikeGrades(courseId);
    }

}
